#include <stdio.h>
#include <dirent.h>
#include <e_file.h>
#include <errno.h>

int main (int argc, char *argv[])
{
	struct stat s;
	DIR *dp = NULL;
	struct dirent *entry;
	if (-1 == stat (argv[1], &s))
	{
		perror ("stat()");
		return -1;
	}
	if (!S_ISDIR(s.st_mode)) {
		fprintf (stderr, "%s is not adirectory\n", argv[1]);
		return -1;
	}
	//打开目录 
	dp = opendir (argv[1]);
	if (NULL == dp) {
		perror ("opendir()");
		return -1;
	}
	//读目录
	while (1) {
		entry = readdir (dp);
		if (NULL == entry) {
			if (errno) {
				perror ("readdir()");
				goto ERROR;
			}
			break;
		}
		printf ("%s--->%s\n", argv[1], entry->d_name);
	}
	closedir (dp);
	return 0;
ERROR:
	closedir (dp);
	return -1;
}




